<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/lib :: reslib('成语首页')"></head>
<body>
<div class="row-fluid" style="width: 300px;margin: 0px auto;">
    <h3>微信小程序-看图知成语小助手</h3>
    <textarea rows="4" style="width: 300px;" id="cy-word" placeholder="请填写成语的组合文字"></textarea><br/>
    <button class="btn btn-primary" onclick="thedo();">获取结果</button>
    <div id="result-target">

    </div>
</div>

<textarea id="result-tpl" style="display: none;">
{{# $.each(d.list, function(index, item){ }}
    {{ index }}:{{= item.cy }}<br/>
{{# }); }}

{{# if(d.list.length == 0){ }}
    未发现成语或者典故
{{# } }}
</textarea>

<script th:inline="javascript">
    /*<![CDATA[*/
    var ctx = [[${ctx}]];
    (function(){

    });
    function thedo(){
        var word = $("#cy-word").val();
        if(word!=undefined && word.length>0){
            var shadeIndex = TOOL.getLayerLoading("正在计算中，请稍等...");
            ajax_post_async(ctx+"/dict/thedo",{"words":word},function(ret){
                layer.close(shadeIndex);
                var data = {};
                data.list = eval("("+ret.msg+")");
                TOOL.renderTpl("result-target","result-tpl",data);
            });
        }else{
            layer.alert("请填写成语的组合文字！");
        }
    }
    /*]]>*/
</script>
</body>
</html>